#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=4e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
vector<char>v[maxn];
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
    LL t;cin>>t;
    while(t--){
        LL n;cin>>n;
        for(LL i=0;i<n+10;i++) v[i].clear();
        for(LL i=1;i<=n;i++){
            string s;cin>>s;
            for(LL j=0;j<s.size();j++) v[i].push_back(s[j]);
        }
        LL ans=0;
        for(LL k=0;k<5;k++){
            char op='a'+k;
            vector<LL>u;
            for(LL i=1;i<=n;i++){
                LL res=0;
                for(LL j=0;j<v[i].size();j++){
                    if(op==v[i][j]) res++;
                }
                LL o=res-(v[i].size()-res);
                u.push_back(o);
            }
            LL cnt=0;
            sort(u.begin(),u.end());
            if(u.empty()) continue;
            LL sum=0;
            for(LL i=u.size()-1;i>=0;i--){
                sum+=u[i];
                if(sum<=0){
                   break;
                }
                else{
                    cnt++;
                }
            }
            ans=max(ans,cnt);
        }
        cout<<ans<<"\n";
    }
   	return 0;
}
